home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / rawstat / rawrpc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-11-30  |  9.6 KB  |  405 lines

  1. /* 
  2.  * rawrpc.c --
  3.  *
  4.  *    Print raw format RPC statistics.
  5.  *
  6.  * Copyright (C) 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifndef lint
  11. static char rcsid[] = "$Header: /sprite/src/cmds/rawstat/RCS/rawrpc.c,v 1.6 90/11/29 23:09:19 kupfer Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14. #include <sprite.h>
  15. #include <stdio.h>
  16. #include <sysStats.h>
  17. #include <option.h>
  18. #include <kernel/sched.h>
  19. #include <vmStat.h>
  20. #include <host.h>
  21. #include <kernel/sync.h>
  22. #include <kernel/timer.h>
  23. #include <kernel/rpcClient.h>
  24. #include <kernel/rpcServer.h>
  25. #include <kernel/rpcCltStat.h>
  26. #include <kernel/rpcSrvStat.h>
  27. #include <kernel/rpcTrace.h>
  28. #include <kernel/rpcCall.h>
  29.  
  30. static ReturnStatus status;
  31. extern int zero;
  32.  
  33. /*
  34.  *----------------------------------------------------------------------
  35.  *
  36.  * PrintRawRpcCltStat --
  37.  *
  38.  *    Prints out the low-level statistics for the client side
  39.  *    of the RPC system.
  40.  *
  41.  * Results:
  42.  *    None.
  43.  *
  44.  * Side effects:
  45.  *    None.
  46.  *
  47.  *----------------------------------------------------------------------
  48.  */
  49.  
  50. PrintRawRpcCltStat()
  51. {
  52.     Rpc_CltStat rpcCltStat;
  53.     Rpc_CltStat *X = &rpcCltStat;
  54.  
  55.     status = Sys_Stats(SYS_RPC_CLT_STATS, TRUE, &rpcCltStat);
  56.     if (status != SUCCESS) {
  57.     return;
  58.     }
  59.     printf("Rpc_CltStat\n");
  60.     ZeroPrint("toClient       %8u\n", X->toClient);
  61.     ZeroPrint("badChannel     %8u\n", X->badChannel);
  62.     ZeroPrint("chanBusy       %8u\n", X->chanBusy);
  63.     ZeroPrint("badId          %8u\n", X->badId);
  64.     ZeroPrint("requests       %8u\n", X->requests);
  65.     ZeroPrint("replies        %8u\n", X->replies);
  66.     ZeroPrint("acks           %8u\n", X->acks);
  67.     ZeroPrint("recvPartial    %8u\n", X->recvPartial);
  68.     ZeroPrint("timeouts       %8u\n", X->timeouts);
  69.     ZeroPrint("aborts         %8u\n", X->aborts);
  70.     ZeroPrint("resends        %8u\n", X->resends);
  71.     ZeroPrint("sentPartial    %8u\n", X->sentPartial);
  72.     ZeroPrint("errors         %8u\n", X->errors);
  73.     ZeroPrint("nullErrors     %8u\n", X->nullErrors);
  74.     ZeroPrint("dupFrag        %8u\n", X->dupFrag);
  75.     ZeroPrint("close          %8u\n", X->close);
  76.     ZeroPrint("oldInputs      %8u\n", X->oldInputs);
  77.     ZeroPrint("badInput       %8u\n", X->badInput);
  78.     ZeroPrint("tooManyAcks    %8u\n", X->tooManyAcks);
  79.     ZeroPrint("chanWaits      %8u\n", X->chanWaits);
  80.     ZeroPrint("chanBroads     %8u\n", X->chanBroads);
  81.     ZeroPrint("chanHits       %8u\n", X->chanHits);
  82.     ZeroPrint("chanNew        %8u\n", X->chanNew);
  83.     ZeroPrint("chanReuse      %8u\n", X->chanReuse);
  84.     ZeroPrint("paramOverrun   %8u\n", X->paramOverrun);
  85.     ZeroPrint("dataOverrun    %8u\n", X->dataOverrun);
  86.     ZeroPrint("shorts         %8u\n", X->shorts);
  87.     ZeroPrint("longs          %8u\n", X->longs);
  88. }
  89.  
  90. /*
  91.  *----------------------------------------------------------------------
  92.  *
  93.  * PrintRawRpcSrvStat --
  94.  *
  95.  *    Prints out the low-level statistics for the service side
  96.  *    of the RPC system.
  97.  *
  98.  * Results:
  99.  *    None.
  100.  *
  101.  * Side effects:
  102.  *    None.
  103.  *
  104.  *----------------------------------------------------------------------
  105.  */
  106.  
  107. PrintRawRpcSrvStat()
  108. {
  109.     Rpc_SrvStat rpcSrvStat;
  110.     Rpc_SrvStat *X = &rpcSrvStat;
  111.  
  112.     status = Sys_Stats(SYS_RPC_SRV_STATS, TRUE, &rpcSrvStat);
  113.     if (status != SUCCESS) {
  114.     return;
  115.     }
  116.     printf("Rpc_SrvStat\n");
  117.     ZeroPrint("toServer       %8u\n", X->toServer);
  118.     ZeroPrint("noAlloc        %8u\n", X->noAlloc);
  119.     ZeroPrint("nacks          %8u\n", X->nacks);
  120.     ZeroPrint("invClient      %8u\n", X->invClient);
  121.     ZeroPrint("serverBusy     %8u\n", X->serverBusy);
  122.     ZeroPrint("requests       %8u\n", X->requests);
  123.     ZeroPrint("impAcks        %8u\n", X->impAcks);
  124.     ZeroPrint("handoffs       %8u\n", X->handoffs);
  125.     ZeroPrint("fragMsgs       %8u\n", X->fragMsgs);
  126.     ZeroPrint("handoffAcks    %8u\n", X->handoffAcks);
  127.     ZeroPrint("fragAcks       %8u\n", X->fragAcks);
  128.     ZeroPrint("sentPartial    %8u\n", X->sentPartial);
  129.     ZeroPrint("busyAcks       %8u\n", X->busyAcks);
  130.     ZeroPrint("resends        %8u\n", X->resends);
  131.     ZeroPrint("badState       %8u\n", X->badState);
  132.     ZeroPrint("extra          %8u\n", X->extra);
  133.     ZeroPrint("reclaims       %8u\n", X->reclaims);
  134.     ZeroPrint("reassembly     %8u\n", X->reassembly);
  135.     ZeroPrint("dupFrag        %8u\n", X->dupFrag);
  136.     ZeroPrint("nonFrag        %8u\n", X->nonFrag);
  137.     ZeroPrint("fragAborts     %8u\n", X->fragAborts);
  138.     ZeroPrint("recvPartial    %8u\n", X->recvPartial);
  139.     ZeroPrint("closeAcks      %8u\n", X->closeAcks);
  140.     ZeroPrint("discards       %8u\n", X->discards);
  141.     ZeroPrint("unknownAcks    %8u\n", X->unknownAcks);
  142.     ZeroPrint("mostNackBufs   %8u\n", X->mostNackBuffers);
  143.     ZeroPrint("selfNacks      %8u\n", X->selfNacks);
  144. }
  145.  
  146. /*
  147.  *----------------------------------------------------------------------
  148.  *
  149.  * PrintSrvCount --
  150.  *
  151.  *    Prints out the number of RPC calls made to this (server) host
  152.  *
  153.  * Results:
  154.  *    None.
  155.  *
  156.  * Side effects:
  157.  *    None.
  158.  *
  159.  *----------------------------------------------------------------------
  160.  */
  161.  
  162. PrintSrvCount()
  163. {
  164.     ReturnStatus status = SUCCESS;
  165.     register int call;
  166.     int rpcServiceCount[RPC_LAST_COMMAND+1];
  167.  
  168.     status = Sys_Stats(SYS_RPC_SRV_COUNTS, sizeof(rpcServiceCount),
  169.                     (Address)rpcServiceCount);
  170.     if (status != SUCCESS) {
  171.     return;
  172.     }
  173.  
  174.     printf("Rpc Service Calls\n");
  175.     for (call=0 ; call<=RPC_LAST_COMMAND ; call++) {
  176.     if (zero || rpcServiceCount[call] > 0) {
  177.         PrintCommand(stdout, call, "%-15s");
  178.         printf("%8u\n", rpcServiceCount[call]);
  179.     }
  180.     }
  181. }
  182.  
  183. /*
  184.  *----------------------------------------------------------------------
  185.  *
  186.  * PrintCallCount --
  187.  *
  188.  *    Prints out the number of RPC calls made by this (client) host
  189.  *
  190.  * Results:
  191.  *    None.
  192.  *
  193.  * Side effects:
  194.  *    None.
  195.  *
  196.  *----------------------------------------------------------------------
  197.  */
  198.  
  199. PrintCallCount()
  200. {
  201.     ReturnStatus status = SUCCESS;
  202.     register int call;
  203.     int rpcClientCalls[RPC_LAST_COMMAND+1];
  204.  
  205.     status = Sys_Stats(SYS_RPC_CALL_COUNTS, sizeof(rpcClientCalls),
  206.                     (Address)rpcClientCalls);
  207.     if (status != SUCCESS) {
  208.     return;
  209.     }
  210.  
  211.     printf("Rpc Client Calls\n");
  212.     for (call=0 ; call<=RPC_LAST_COMMAND ; call++) {
  213.     if (zero || rpcClientCalls[call] > 0) {
  214.         PrintCommand(stdout, call, "%-15s");
  215.         printf("%8u\n", rpcClientCalls[call]);
  216.     }
  217.     }
  218. }
  219.  
  220. /*
  221.  *----------------------------------------------------------------------
  222.  *
  223.  * PrintHostName --
  224.  *
  225.  *    Prints out the host name and trims of the internet domain suffix.
  226.  *
  227.  * Results:
  228.  *    None.
  229.  *
  230.  * Side effects:
  231.  *    None.
  232.  *
  233.  *----------------------------------------------------------------------
  234.  */
  235.  
  236. PrintHostName(spriteID, format)
  237.     int spriteID;
  238.     char *format;
  239. {
  240.     Host_Entry *entryPtr;
  241.     char string[64];
  242.     char *cPtr;
  243.  
  244.     entryPtr = Host_ByID(spriteID);
  245.     if (entryPtr == (Host_Entry *)NULL) {
  246.     sprintf(string, "%d", spriteID);
  247.     ZeroPrint(format, string);
  248.     } else {
  249.     for (cPtr = entryPtr->name ; *cPtr ; cPtr++) {
  250.         /*
  251.          * Strip off the domain suffix.
  252.          */
  253.         if (*cPtr == '.') {
  254.         *cPtr = '\0';
  255.         break;
  256.         }
  257.     }
  258.     ZeroPrint(format, entryPtr->name);
  259.     }
  260. }
  261.  
  262. /*
  263.  * PrintCommand --
  264.  *
  265.  *    Convert from procedure ID to procedure name and output it.
  266.  */
  267. PrintCommand(stream, command, format)
  268.     FILE *stream;
  269.     int command;
  270.     char *format;
  271. {
  272.     char buffer[128];
  273.     char *string;
  274.  
  275.     switch (command) {
  276.     case RPC_ECHO_1:
  277.         string = "echoIntr";
  278.         break;
  279.     case RPC_ECHO_2:
  280.         string = "echo";
  281.         break;
  282.     case RPC_SEND:
  283.         string = "send";
  284.         break;
  285.     case RPC_RECEIVE:
  286.         string = "recv";
  287.         break;
  288.     case RPC_GETTIME:
  289.         string = "get_time";
  290.         break;
  291.     case RPC_FS_PREFIX:
  292.         string = "prefix";
  293.         break;
  294.     case RPC_FS_OPEN:
  295.         string = "open";
  296.         break;
  297.     case RPC_FS_READ:
  298.         string = "read";
  299.         break;
  300.     case RPC_FS_WRITE:
  301.         string = "write";
  302.         break;
  303.     case RPC_FS_CLOSE:
  304.         string = "close";
  305.         break;
  306.     case RPC_FS_UNLINK:
  307.         string = "remove";
  308.         break;
  309.     case RPC_FS_RENAME:
  310.         string = "rename";
  311.         break;
  312.     case RPC_FS_MKDIR:
  313.         string = "mkdir";
  314.         break;
  315.     case RPC_FS_RMDIR:
  316.         string = "rmdir";
  317.         break;
  318.     case RPC_FS_MKDEV:
  319.         string = "make_dev";
  320.         break;
  321.     case RPC_FS_LINK:
  322.         string = "link";
  323.         break;
  324.     case RPC_FS_SYM_LINK:
  325.         string = "link";
  326.         break;
  327.     case RPC_FS_GET_ATTR:
  328.         string = "get_attrID";
  329.         break;
  330.     case RPC_FS_SET_ATTR:
  331.         string = "set_attrID";
  332.         break;
  333.     case RPC_FS_GET_ATTR_PATH:
  334.         string = "get_attr";
  335.         break;
  336.     case RPC_FS_SET_ATTR_PATH:
  337.         string = "set_attr";
  338.         break;
  339.     case RPC_FS_GET_IO_ATTR:
  340.         string = "getI/Oattr";
  341.         break;
  342.     case RPC_FS_SET_IO_ATTR:
  343.         string = "setI/Oattr";
  344.         break;
  345.     case RPC_FS_DEV_OPEN:
  346.         string = "dev_open";
  347.         break;
  348.     case RPC_FS_SELECT:
  349.         string = "select";
  350.         break;
  351.     case RPC_FS_IO_CONTROL:
  352.         string = "ioctl";
  353.         break;
  354.     case RPC_FS_CONSIST:
  355.         string = "consist";
  356.         break;
  357.     case RPC_FS_CONSIST_REPLY:
  358.         string = "cnsst_rply";
  359.         break;
  360.     case RPC_FS_COPY_BLOCK:
  361.         string = "block_copy";
  362.         break;
  363.     case RPC_FS_MIGRATE:
  364.         string = "mig_file";
  365.         break;
  366.     case RPC_FS_RELEASE:
  367.     case RPC_FS_RELEASE_NEW:
  368.         string = "release";
  369.         break;
  370.     case RPC_FS_REOPEN:
  371.         string = "reopen";
  372.         break;
  373.     case RPC_FS_RECOVERY:
  374.         string = "recov";
  375.         break;
  376.     case RPC_FS_DOMAIN_INFO:
  377.         string = "domain_info";
  378.         break;
  379.     case RPC_PROC_MIG_COMMAND:
  380.         string = "mig_cmd";
  381.         break;
  382.     case RPC_PROC_REMOTE_CALL:
  383.         string = "mig_call";
  384.         break;
  385.     case RPC_PROC_REMOTE_WAIT:
  386.         string = "wait";
  387.         break;
  388.     case RPC_PROC_GETPCB:
  389.         string = "getpcb";
  390.         break;
  391.     case RPC_REMOTE_WAKEUP:
  392.         string = "wakeup";
  393.         break;
  394.     case RPC_SIG_SEND:
  395.         string = "signal";
  396.         break;
  397.     default: {
  398.         sprintf(buffer,"%d",command);
  399.         string = buffer;
  400.         break;
  401.     }
  402.     }
  403.     fprintf(stream, format, string);
  404. }
  405.